//
//  MingXiBottom.swift
//  旅航ios
//
//  Created by tulip on 2021/5/10.
//

import UIKit

class MingXiBottom: UIView {
    var peopleNum:UILabel!
    var ticketNum:UILabel!
    var fuNum:UILabel!
    var baoxianNum:UILabel!
    var baoxian:UILabel!
    var propStatus:(()->Void)?
    override init(frame: CGRect) { // heigt :  SCREEN_HEIGHT-60-BottomSpaceHeigh

        super.init(frame: frame)
        
        self.backgroundColor=UIColor.black.withAlphaComponent(0.6)
        
        let boxview=UIView.init(frame: CGRect(x: 0, y: frame.size.height-175, width: SCREEN_WIDTH, height: 175))
        boxview.backgroundColor=UIColor.white
        self.addSubview(boxview)
        
        let people=UILabel.init(frame: CGRect(x: 15, y: 34, width: 50, height: 16))
        people.text="成人"
        people.font=UIFont.systemFont(ofSize: 15)
        people.textColor=UIColor.init(hexString: "333333")
        boxview.addSubview(people)
        
        peopleNum=UILabel.init(frame: CGRect(x: SCREEN_WIDTH-165, y: 34, width: 150, height: 16))
        peopleNum.textAlignment = .right
        peopleNum.textColor=UIColor.init(hexString: "333333")
        peopleNum.font=UIFont.systemFont(ofSize: 15)
        boxview.addSubview(peopleNum)
        
        let ticket=UILabel.init(frame: CGRect(x: 15, y: 70, width: 50, height: 16))
        ticket.textAlignment = .left
        ticket.text="机票"
        ticket.textColor=UIColor.init(hexString: "999999")
        ticket.font=UIFont.systemFont(ofSize: 12)
        boxview.addSubview(ticket)
        
        ticketNum=UILabel.init(frame: CGRect(x: SCREEN_WIDTH-165, y: 70, width: 150, height: 16))
        ticketNum.textAlignment = .right
        ticketNum.textColor=UIColor.init(hexString: "999999")
        ticketNum.font=UIFont.systemFont(ofSize: 12)
        boxview.addSubview(ticketNum)
        
        let fu=UILabel.init(frame: CGRect(x: 15, y: 94, width: 50, height: 16))
        fu.textAlignment = .left
        fu.text="机建燃油"
        fu.textColor=UIColor.init(hexString: "999999")
        fu.font=UIFont.systemFont(ofSize: 12)
        boxview.addSubview(fu)
        
        fuNum=UILabel.init(frame: CGRect(x: SCREEN_WIDTH-165, y: 94, width: 150, height: 16))
        fuNum.textAlignment = .right
        fuNum.textColor=UIColor.init(hexString: "999999")
        fuNum.font=UIFont.systemFont(ofSize: 12)
        boxview.addSubview(fuNum)
        
        baoxian=UILabel.init(frame: CGRect(x: 15, y: 120, width: 50, height: 16))
        baoxian.textAlignment = .left
        baoxian.text="保险"
        baoxian.textColor=UIColor.init(hexString: "999999")
        baoxian.font=UIFont.systemFont(ofSize: 12)
        boxview.addSubview(baoxian)
        
        baoxianNum=UILabel.init(frame: CGRect(x: SCREEN_WIDTH-165, y: 120, width: 150, height: 16))
        baoxianNum.textAlignment = .right
        baoxianNum.textColor=UIColor.init(hexString: "999999")
        baoxianNum.font=UIFont.systemFont(ofSize: 12)
        boxview.addSubview(baoxianNum)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.removeFromSuperview()
        if propStatus != nil {
            self.propStatus!()
        }
    }
    func setPrice(tk:Int,fu:Int,bx:Int,num:Int){
       
        ticketNum.text="¥ " + String(tk) + "X" + String(num) + "人"
        fuNum.text="¥ " + String(fu) + "X" + String(num) + "人"
        baoxianNum.text="¥ " + String(bx) + "X" + String(num) + "人"
        peopleNum.text="¥ " + String(tk+fu+bx) + "X" + String(num) + "人"
        
        if bx == 0 {
            baoxian.isHidden=true
            baoxianNum.isHidden=true
        }
        
        
        
    }
}
